
/**
 * 
 * @param {Array} menulist 用户的菜单信息，用于和allRoutes进行比对
 * @param {Array} allRoutes 用户的完成动态路由表
 */
let recursionRoutes = ((menulist = [], allRoutes = [])=>{
    // 用于防止对比之后的路有数据
    let userRoutes = []

    menulist.length > 0 && menulist.forEach(menu => {
        
        allRoutes.forEach(route =>{
            if(menu.title===route.meta.title){
                if(menu.children && menu.children.length > 0){
                    // 如果有children属性需要递归重新计算
                    route.children = recursionRoutes(menu.children,route.children)
                }
                userRoutes.push(route)
            }
        })
    })
    return userRoutes
})

export default recursionRoutes